Optical Flow Program

import module

%matplotlib notebook
import akhdefo_functions
from akhdefo_functions import DynamicChangeDetection

Notes:

coh_Thresh

Default=0.2 (max is 1) The higher is the more accuate velocity measurments but you endup with less number of velocity measurement points. This threshold indicates the similarity percentage between pixels at different time.

vel_thresh

Default=1 pixel : any measurment points has velocity higher than vel_thresh will be ignored

for example if your raster image has resolution of 1 pixel to 3 meters then the program can only detect velocity movement up to 3 meters/day.

This will define largest velocity magnitude amount to be measured.

-At this step the velocity products include real velocity and noise. we can correct those later at stackprep and timeseries steps.


_DailyVelocities=DynamicChangeDetection(Path_working_Directory="data/cropped_rasters", 
 Path_to_DEMFile="data/dem_aoi.tif", Coh_Thresh=0.2, vel_thresh=1,image_sensor_resolution=3125.0,
udm_mask_option=False, cmap='Spectral', Median_Filter=True ,
Set_fig_MinMax=True, show_figure=True, plot_option="origional", out_dir="data" , AOI_shapefile="data/AOI.shp")
day_of_the_year_date1:  224
---------------------
day_of_the_year_date2:  229
---------------------
day_of_the_year_date3:  232
---------------------
Delta_DD: 8
shift:im1 and im2 [-0.05  0.  ] phasediff: 4.717751109140468e-18 error: 1.0
shift:im1 and im3 [-0.05  0.  ] phasediff: -1.1304532982879778e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220812-20220817-20220820
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220812-20220817-20220820
day_of_the_year_date1:  229
---------------------
day_of_the_year_date2:  232
---------------------
day_of_the_year_date3:  234
---------------------
Delta_DD: 5
shift:im1 and im2 [0. 0.] phasediff: -1.5716717576979767e-18 error: 1.0
shift:im1 and im3 [0. 0.] phasediff: -4.0394550177597076e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220817-20220820-20220822
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220817-20220820-20220822
day_of_the_year_date1:  232
---------------------
day_of_the_year_date2:  234
---------------------
day_of_the_year_date3:  237
---------------------
Delta_DD: 5
shift:im1 and im2 [0. 0.] phasediff: -8.08254683824406e-19 error: 1.0
shift:im1 and im3 [0. 0.] phasediff: -2.419502160937536e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220820-20220822-20220825
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220820-20220822-20220825
day_of_the_year_date1:  234
---------------------
day_of_the_year_date2:  237
---------------------
day_of_the_year_date3:  242
---------------------
Delta_DD: 8
shift:im1 and im2 [0. 0.] phasediff: -3.221841265809663e-18 error: 1.0
shift:im1 and im3 [0.05 0.05] phasediff: -1.3762799007792429e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220822-20220825-20220830
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220822-20220825-20220830
day_of_the_year_date1:  237
---------------------
day_of_the_year_date2:  242
---------------------
day_of_the_year_date3:  243
---------------------
Delta_DD: 6
shift:im1 and im2 [0.05 0.05] phasediff: -1.8990126411072452e-17 error: 1.0
shift:im1 and im3 [0. 0.] phasediff: 1.1376165167428248e-19 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220825-20220830-20220831
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220825-20220830-20220831
day_of_the_year_date1:  242
---------------------
day_of_the_year_date2:  243
---------------------
day_of_the_year_date3:  244
---------------------
Delta_DD: 2
shift:im1 and im2 [-0.05 -0.05] phasediff: 1.8927340114974694e-17 error: 1.0
shift:im1 and im3 [ 0.  -0.1] phasediff: 8.268421890289804e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220830-20220831-20220901
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220830-20220831-20220901
day_of_the_year_date1:  243
---------------------
day_of_the_year_date2:  244
---------------------
day_of_the_year_date3:  245
---------------------
Delta_DD: 2
shift:im1 and im2 [ 0.05 -0.05] phasediff: 7.142192400815001e-18 error: 1.0
shift:im1 and im3 [0. 0.] phasediff: -1.7257448440062849e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220831-20220901-20220902
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220831-20220901-20220902
day_of_the_year_date1:  244
---------------------
day_of_the_year_date2:  245
---------------------
day_of_the_year_date3:  246
---------------------
Delta_DD: 2
shift:im1 and im2 [-0.05  0.  ] phasediff: -3.4295703589793808e-18 error: 1.0
shift:im1 and im3 [-0.05  0.  ] phasediff: 5.327979524605528e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220901-20220902-20220903
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220901-20220902-20220903
day_of_the_year_date1:  245
---------------------
day_of_the_year_date2:  246
---------------------
day_of_the_year_date3:  250
---------------------
Delta_DD: 5
shift:im1 and im2 [-0.05  0.  ] phasediff: 6.055966954506303e-18 error: 1.0
shift:im1 and im3 [ 0.15 -0.05] phasediff: -1.6631883600386198e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220902-20220903-20220907
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220902-20220903-20220907
day_of_the_year_date1:  246
---------------------
day_of_the_year_date2:  250
---------------------
day_of_the_year_date3:  252
---------------------
Delta_DD: 6
shift:im1 and im2 [ 0.2  -0.05] phasediff: -7.92616575418381e-17 error: 1.0
shift:im1 and im3 [0. 0.] phasediff: 7.579739775092242e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220903-20220907-20220909
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220903-20220907-20220909
day_of_the_year_date1:  250
---------------------
day_of_the_year_date2:  252
---------------------
day_of_the_year_date3:  253
---------------------
Delta_DD: 3
shift:im1 and im2 [-0.1   0.05] phasediff: -2.5640592007317957e-17 error: 1.0
shift:im1 and im3 [-0.1   0.05] phasediff: 7.244922784686724e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220907-20220909-20220910
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220907-20220909-20220910
day_of_the_year_date1:  252
---------------------
day_of_the_year_date2:  253
---------------------
day_of_the_year_date3:  256
---------------------
Delta_DD: 4
shift:im1 and im2 [0. 0.] phasediff: 3.8626226210265335e-18 error: 1.0
shift:im1 and im3 [0.1 0. ] phasediff: 3.5989674087198334e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220909-20220910-20220913
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220909-20220910-20220913
day_of_the_year_date1:  253
---------------------
day_of_the_year_date2:  256
---------------------
day_of_the_year_date3:  261
---------------------
Delta_DD: 8
shift:im1 and im2 [0.1 0. ] phasediff: -2.88337135195996e-17 error: 1.0
shift:im1 and im3 [-0.05  0.  ] phasediff: -2.1491819315812112e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220910-20220913-20220918
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220910-20220913-20220918
day_of_the_year_date1:  256
---------------------
day_of_the_year_date2:  261
---------------------
day_of_the_year_date3:  262
---------------------
Delta_DD: 6
shift:im1 and im2 [-0.1  0. ] phasediff: 2.1501035483767388e-17 error: 1.0
shift:im1 and im3 [0. 0.] phasediff: -6.594167845634941e-19 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220913-20220918-20220919
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220913-20220918-20220919
day_of_the_year_date1:  261
---------------------
day_of_the_year_date2:  262
---------------------
day_of_the_year_date3:  263
---------------------
Delta_DD: 2
shift:im1 and im2 [0.1 0. ] phasediff: -1.640696379469863e-17 error: 1.0
shift:im1 and im3 [-0.05  0.05] phasediff: -2.5562100690226632e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220918-20220919-20220920
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220918-20220919-20220920
day_of_the_year_date1:  262
---------------------
day_of_the_year_date2:  263
---------------------
day_of_the_year_date3:  264
---------------------
Delta_DD: 2
shift:im1 and im2 [-0.1   0.05] phasediff: 3.9488284112751946e-17 error: 1.0
shift:im1 and im3 [0.   0.05] phasediff: -0.0 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220919-20220920-20220921
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220919-20220920-20220921
day_of_the_year_date1:  263
---------------------
day_of_the_year_date2:  264
---------------------
day_of_the_year_date3:  268
---------------------
Delta_DD: 5
shift:im1 and im2 [0.05 0.  ] phasediff: 1.4231656544438225e-17 error: 1.0
shift:im1 and im3 [ 0.05 -0.05] phasediff: 2.1054127616476953e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220920-20220921-20220925
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220920-20220921-20220925
day_of_the_year_date1:  264
---------------------
day_of_the_year_date2:  268
---------------------
day_of_the_year_date3:  270
---------------------
Delta_DD: 6
shift:im1 and im2 [ 0.05 -0.05] phasediff: 9.264266856129101e-18 error: 1.0
shift:im1 and im3 [0.   0.05] phasediff: -0.0 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220921-20220925-20220927
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220921-20220925-20220927
day_of_the_year_date1:  268
---------------------
day_of_the_year_date2:  270
---------------------
day_of_the_year_date3:  272
---------------------
Delta_DD: 4
shift:im1 and im2 [0.   0.05] phasediff: 2.2811549647713743e-18 error: 1.0
shift:im1 and im3 [-0.55 -0.15] phasediff: 6.555413812437165e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220925-20220927-20220929
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220925-20220927-20220929
day_of_the_year_date1:  270
---------------------
day_of_the_year_date2:  272
---------------------
day_of_the_year_date3:  274
---------------------
Delta_DD: 4
shift:im1 and im2 [-0.45 -0.2 ] phasediff: 5.2521480521119326e-17 error: 1.0
shift:im1 and im3 [0.1 0. ] phasediff: -0.0 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220927-20220929-20221001
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220927-20220929-20221001
day_of_the_year_date1:  272
---------------------
day_of_the_year_date2:  274
---------------------
day_of_the_year_date3:  275
---------------------
Delta_DD: 3
shift:im1 and im2 [0.6  0.05] phasediff: 1.9777362515309043e-17 error: 1.0
shift:im1 and im3 [0.25 0.  ] phasediff: -2.764775282094521e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20220929-20221001-20221002
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20220929-20221001-20221002
day_of_the_year_date1:  274
---------------------
day_of_the_year_date2:  275
---------------------
day_of_the_year_date3:  276
---------------------
Delta_DD: 2
shift:im1 and im2 [-0.2  -0.05] phasediff: -1.6625359407336397e-17 error: 1.0
shift:im1 and im3 [ 0.  -0.1] phasediff: -8.427766566958359e-18 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20221001-20221002-20221003
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20221001-20221002-20221003
day_of_the_year_date1:  275
---------------------
day_of_the_year_date2:  276
---------------------
day_of_the_year_date3:  279
---------------------
Delta_DD: 4
shift:im1 and im2 [ 0.1  -0.05] phasediff: 8.155857712872312e-18 error: 1.0
shift:im1 and im3 [0.15 0.05] phasediff: 3.2759902744516504e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20221002-20221003-20221006
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20221002-20221003-20221006
day_of_the_year_date1:  276
---------------------
day_of_the_year_date2:  279
---------------------
day_of_the_year_date3:  281
---------------------
Delta_DD: 5
shift:im1 and im2 [0.05 0.05] phasediff: -1.4196105404425937e-17 error: 1.0
shift:im1 and im3 [-0.2  -0.05] phasediff: -2.4218305527219617e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20221003-20221006-20221008
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
Finished Processing Triplet Dates:  20221003-20221006-20221008
day_of_the_year_date1:  279
---------------------
day_of_the_year_date2:  281
---------------------
day_of_the_year_date3:  289
---------------------
Delta_DD: 10
shift:im1 and im2 [-0.3 -0.1] phasediff: -6.960370336838412e-17 error: 1.0
shift:im1 and im3 [-0.8  0.7] phasediff: 4.250574572252816e-17 error: 1.0
(519, 615) :  (519, 615) :  (519, 615)
(519, 615)
(519, 615)
Now Processing Triplet Dates:  20221006-20221008-20221016
 User selected to ignore resampling raster images 



<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
 process is compeleted